//
//  CZVistorController.swift
//  CZWeibo
//
//  Created by 左凯旭 on 16/8/9.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CZVistorController: UIViewController {

    var islogin:Bool = CZUserAccountViewModel.shareTools.isLogin
    //这样外界才可以访问
    var visitorView: CZVistorView?
    
    
    override func loadView() {
        
        if islogin {
            
           view = tableview
            
        }else{
            setupVisitorView()
        }
    }
    
    
    
    
    //设置访客界面
    func setupVisitorView(){
        setupNav()
        visitorView = CZVistorView()
        
        //02 闭包实例化
        visitorView?.closure = {
//            04 
            self.loginAction()
        }
        
        
        view = visitorView
    }
    
    //设置导航栏
    func setupNav(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
    }
    
    //MARK - 按钮监听
    func loginAction(){
//        print("登陆和注册按钮")
        
        let OAuthVC = CZOAuthViewController()
        //跳转
        presentViewController(UINavigationController(rootViewController:OAuthVC), animated: true, completion: nil)
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    
    
    //懒加载控件
   lazy var tableview:UITableView = UITableView()
    
    
}
